<template>
	<view class="main">
		<view class="flex align between topSearch">
			<view style="width: 75%;">
				<u-search placeholder="输入任务名称搜索" bgColor="#fff" :showAction="false" v-model="merge_keyword" @change="change"></u-search>
			</view>
			<view class="addBtn flex align" @click="toUrl('/pages/videoManage/videoTimeAdd')">人工发布矩阵
				<!-- <uni-icons type="plus" size="20" color="#fff"></uni-icons> -->
			</view>
		</view>
		<!-- <view class="lookNav flex align">
			<view class="flex align" @click="show2 = true">
				阅读平台发布规则
				<uni-icons type="plus" size="20" color="#797979"></uni-icons>
			</view>
			<view style="margin: 0 10rpx;">|</view>
			<view class="flex align" @click="show = true">
				筛选
				<uni-icons type="settings" size="20" color="#797979"></uni-icons>
			</view>
		</view> -->
		<view class="list" v-for="(item,index) in list" :key="index">
			<view class="name flex align between">
				<view>{{item.title}}</view>
				<view>{{item.addtime}}</view>
			</view>
			<view class="flex between info">
				<view class="info-info">
					<view class="flex align between info-item">
						<view>发送方案</view>
						<view>10</view>
					</view>
					<view class="flex align between info-item">
						<view>今日已发送</view>
						<view>5</view>
					</view>
					<view class="flex align between info-item">
						<view>当前等待发送</view>
						<view>3</view>
					</view>
					<view class="flex align between info-item">
						<view>今日发送失败</view>
						<view>1</view>
					</view>
					<view class="flex align between info-item">
						<view>选中用户</view>
						<view>云媒科技</view>
					</view>
					<view class="flex align between info-item">
						<view>总发送成功</view>
						<view>{{item.sended_all}}</view>
					</view>
					<view class="flex align between info-item">
						<view>预计下次发布</view>
						<view>{{item.next_date}}</view>
					</view>
					<view class="flex align between info-item">
						<view>添加时间</view>
						<view>{{item.addtime}}</view>
					</view>
				</view>
				<view class="info-info2">
					
					<view class="info-status">状态</view>
					<view class="info-btn">已发送/暂停</view>
				</view>
			</view>
			<view class="delBtn flex align">
				<uni-icons type="trash" size="20" color="#fff"></uni-icons>
				删除
			</view>
			<!-- <view class="look" @click="toUrl('/pages/employee/look')">查看</view> -->
		</view>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
		<u-popup :show="show" :round="10" mode="bottom">
			<view class="btomShow">
				<view class="closeempty" @click="show = false">
					<uni-icons type="closeempty" size="30"></uni-icons>
				</view>
				<view class="showTit">筛选</view>
				<view class="title">类型</view>
				<input placeholder="请选择" disabled />
				<view class="title">任务状态</view>
				<input placeholder="请选择" disabled />
				<view class="title">预计发布时间</view>
				<input placeholder="请选择" disabled />
				<view class="title">数据更新</view>
				<input placeholder="请选择" disabled />
				<view class="title">添加时间</view>
				<input placeholder="请选择" disabled />
				<view class="subBtn">确定</view>
			</view>
		</u-popup>
		<u-popup :show="show2" :round="10" mode="bottom">
			<view class="btomShow">
				<view class="closeempty" @click="show2 = false">
					<uni-icons type="closeempty" size="30"></uni-icons>
				</view>
				<view class="showTit">阅读平台发布规则</view>
				<view class="content">
					抖音规则
					1、视频文件大小不超过128M，时长在15分钟以内。
					2、带品牌logo或品牌水印的视频，会命中抖音的审核逻辑，有比较大的概率导致分享视频推荐降权处理/分享视频下架处理/分享账号被封禁处理。强烈建议第三方应用自行处理好分享内容中的不合规水印。
					3、视频过短或视频内容低俗，会导致分享视频推荐降权处理/分享视频下架处理/分享账号被封禁处理。
					
					西瓜规则
					1、视频文件大小不超过128M，时长在1分钟以内。
					2、标题+话题不超过30个中英文字符。
					3、带品牌logo或品牌水印的视频，会命中抖音的审核逻辑，
				</view>
				
				<view class="subBtn" @click="show2 = false">确定</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		tuiguangTaskAutoIndex,
		rankDel
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				keyword: '',
				show: false,
				show2: false,
				totalPage: 1,
				page: 0,
				offset: 20,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				merge_keyword: '',
			};
		},
		onShow() {
			this.page = 0
			this.list = []
			this.getlist()
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			toUrl(u) {
				uni.navigateTo({
					url: u
				})
			},
			change() {
				this.page = 0
				this.list = []
				this.getlist()
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					group_id,
					type,
					merge_keyword,
					statusA,
					rank_id
				} = that;
			
				let obj = {
					menu_url: 'tuiguang_task_auto',
					limit: offset,
					offset: page,
					sort: 'id',
					order: 'desc',
					_: new Date().getTime(),
					filter: {},
					op: {}
					// filter:merge_keyword=='',
					// op:encodeURIComponent(JSON.stringify(filter))
				};
				if (merge_keyword != '') {
					obj.filter = JSON.stringify({
						"title": merge_keyword.toString()
					})
					obj.op = JSON.stringify({
						"title": 'LIKE'
					})
				}
				that.status = 'loading';
				if (totalPage > page) {
					let result = await tuiguangTaskAutoIndex(obj);
					that.page = page + 1;
					if (result.total == 0) {
						that.empty = true;
						that.status = 'nomore';
						return;
					}
					that.empty = false;
					setTimeout(() => {
						that.status = 'loadmore';
					}, 500);
					that.list = list.concat(result.rows);
					that.totalPage = Math.ceil(result.total / offset);
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		margin: 13rpx 30rpx;

		.topSearch {
			margin-bottom: 14rpx;

			.addBtn {
				background: #FFCDB8;
				color: white;
				border-radius: 14rpx;
				font-size: 20rpx;
				padding: 8rpx 14rpx;
			}
		}

		.lookNav {
			color: #797979;
			font-size: 24rpx;
			text-align: right;
			justify-content: flex-end;
			margin-bottom: 26rpx;
		}

		.list {
			background: white;
			box-shadow: 1rpx 1rpx 5rpx 1rpx gainsboro;
			border-radius: 15rpx;
			margin-bottom: 50rpx;

			.name {
				margin: 0 17rpx;
				padding: 26rpx 15rpx 8rpx;
				border-bottom: solid 1rpx #D6D6D6;

				view:nth-child(1) {
					font-size: 28rpx;
					font-weight: bold;
				}

				view:nth-child(2) {
					font-size: 18rpx;
					color: #868686;
				}
			}

			.info {
				font-size: 18rpx;
				padding: 14rpx 41rpx;

				.info-info {
					width: 60%;

					.info-item {
						line-height: 1.5;

						view:nth-child(2) {
							width: 50%;
							font-weight: bold;
							text-align: center;
						}
					}
				}

				.info-info2 {
					width: 36%;
					font-size: 24rpx;
					text-align: center;

					.info-status {
						text-align: center;
						margin-top: 15rpx;
					}

					.info-btn {
						background: #369805;
						border-radius: 33rpx;
						color: white;
						padding: 2rpx 13rpx;
						width: fit-content;
						margin: 0 auto;
					}
				}
			}

			.look {
				border-radius: 0 0 15rpx 15rpx;
				text-align: center;
				color: white;
				font-weight: bold;
				font-size: 32rpx;
				padding: 12rpx 0;
				background: #2D2D2D;
			}
		}

		.btomShow {
			padding: 0 28rpx 50rpx;
			position: relative;
			.content{
				font-size: 20rpx;
				
			}

			.showTit {
				text-align: center;
				font-size: 32rpx;
				font-weight: bold;
				padding: 33rpx 0;
			}

			input {
				font-size: 20rpx;
				padding: 16rpx 24rpx;
				border-radius: 10rpx;
				border: solid 1rpx #707070;
			}

			.closeempty {
				position: absolute;
				top: 20rpx;
				right: 30rpx;

			}

			.title {
				font-size: 28rpx;
				margin: 25rpx 0;
			}

			.subBtn {
				font-size: 30rpx;
				color: white;
				padding: 8rpx 95rpx;
				background: #5D9CEB;
				width: fit-content;
				margin: 37rpx auto 0rpx;
				border-radius: 10rpx;
			}

		}

		.delBtn {
			justify-content: center;
			background: #2D2D2D;
			border-radius: 0 0 15rpx 15rpx;
			color: white;
			font-weight: bold;
			padding: 12rpx 0;
		}
	}
</style>